import "babel-polyfill";
import Vue from "vue";
// import * as echarts from 'echarts';
import moment from "moment";
import axios from "axios";
import App from "./App";
import router from "./router";
import store from "./store";
import i18n from "./i18n";
import request from "./service/service";
import Util from "./utils/util";
import * as ct from "./utils/ct.js";
import "./assets/styles/base.scss";
import { Message, MessageBox } from "element-ui";
import "./utils/element";
import Model from "@/model";
// import 'echarts-gl';
import configs from "./service/config";
import "./utils/filter";
import { mixin } from "./mixins/mixins";

Vue.config.productionTip = false;
Vue.prototype.$request = request;
Vue.prototype.$axios = axios;

Object.keys(Util).forEach(key => {
  Vue.prototype[`$${key}`] = Util[key];
});

// 经纬度坐标设置
Vue.prototype["$CT"] = ct;

// 设置rem
Util.setRem();
window.onresize = function() {
  Util.setRem();
};

Vue.prototype.$message = {
  success: function(message) {
    Message.success({
      message: message,
      duration: 1500,
      center: true
    });
  },
  error: function(message) {
    Message.error({
      message: message,
      duration: 1500,
      center: true
    });
  },
  warning: function(message) {
    Message.warning({
      message: message,
      duration: 1500,
      center: true
    });
  }
};

Vue.prototype.$confirm = MessageBox.confirm;

// 挂载echarts
Vue.prototype.$echarts = window.echarts;

Vue.prototype.$moment = moment;

// 挂载请求
Vue.prototype.$Model = Model;

// 项目配置
Vue.prototype.$configs = configs;

Vue.directive("focus", {
  inserted: function(el) {
    el.focus();
  }
});

// 混入权限
Vue.mixin({
  ...mixin
});

window.app = new Vue({
  el: "#app",
  router,
  store,
  i18n,
  components: { App },
  template: "<App/>"
});
